const util = require('../../utils/util.js');
const api = require('../../config/api.js');
const user = require('../../services/user.js');

//获取应用实例
const app = getApp()
Page({
    data: {
        stores: [],
        mans: [],
        topics: [],
        brands: [],
        floorGoods: [],
        banner: [],
        channel: []
    },
    onShareAppMessage: function () {
        return {
            title: '邻邦妮',
            desc: '人才',
            path: '/pages/index/index'
        }
    }, onPullDownRefresh() {
        // 增加下拉刷新数据的功能
        var self = this;
        this.getIndexData();
    },
    getIndexData: function () {
        let that = this;
        var data = new Object();
        util.request(api.StoreUrl, {}, 'GET').then(function (res) {
            if (res.code === 200) {
                data.stores = res.rows
                that.setData(data);
            }
        });
        util.request(api.ManUrl,{
            orderByColumn: "visit",
            isAsc: "desc",
            pageSize: 10,
            pageNum:1
          },"POST").then(function (res) {
            if (res.code === 200) {
                data.mans = res.list
                that.setData(data);
            }
        });
        // util.request(api.IndexUrlTopic).then(function (res) {
        //     if (res.code === "0000") {
        //         data.topics = res.data.topicList
        //         that.setData(data);
        //     }
        // });
        // util.request(api.IndexUrlBrand).then(function (res) {
        //     if (res.code === "0000") {
        //         data.brand = res.data.brandList
        //         that.setData(data);
        //     }
        // });
        // util.request(api.IndexUrlCategory).then(function (res) {
        //     if (res.code === "0000") {
        //         data.floorGoods = res.data.categoryList
        //         that.setData(data);
        //     }
        // });
        // util.request(api.IndexUrlBanner).then(function (res) {

        //     if (res.code === "0000") {
        //         data.banner = res.data.banner
        //         that.setData(data);
        //     }
        // });
        // util.request(api.IndexUrlChannel).then(function (res) {
        //     if (res.code === "0000") {
        //         data.channel = res.data.channel
        //         that.setData(data);
        //     }
        // });

    },
    onLoad: function (options) {
        this.getIndexData();
    },
    onReady: function () {
        // 页面渲染完成
    },
    onShow: function () {
        // 页面显示
    },
    onHide: function () {
        // 页面隐藏
    },
    onUnload: function () {
        // 页面关闭
    },
})
